Learn R Programming

fastR (version 1.1)

Many t-tests: Many t-tests

Description

It performs very many t-tests.

Usage

ttests(x, ina, paired = FALSE)

Arguments

x
A matrix with the data, where the rows denote the samples (and the two groups) and the columns are the variables.
ina
A numerical vector with 1s and 2s indicating the two groups. Be careful, the funciton is desinged to accept only these two numbers.
paired
If the groups are not independent paired t-tests should be performed and this must be TRUE, otherwise, leave it FALSE. In this case, the two groups must have equal smaple sizes, otherwise no test will be performed.

Value

A matrix with the test statistic, the degrees of freedom (if the groups are independent) and the p-value of each test.

Details

If the groups are independent, the Welch's t-test (without assuming equal variances) is performed. Otherwise many paired t-tests are performed.

References

B. L. Welch (1951). On the comparison of several mean values: an alternative approach. Biometrika, 38(3/4), 330-336.

See Also

colVars

Examples

Run this code
## 100000 variables, hence 100000 t-tests will be performed
x = matrix( rnorm(100 * 100000), ncol = 100000 )
## 100 observations in total
ina = rbinom(100, 1, 0.6) + 1   ## independent samples t-test
system.time( ttests(x, ina) )

ina = rep(1:2, each = 50)   ## dependent samples t-test
system.time( ttests(x, ina, paired = TRUE) )

Run the code above in your browser using DataLab